<template>
  <div class="app-container">
    <el-row>
      <el-col :span="24">
        <div class="h_top">
          <div class="bread_title">
            <span>新增文档</span>
          </div>
          <div class="add_button">
            <div class="buttonBox">
              <el-button type="primary" icon="el-icon-document-checked" size="mini" @click="save">保存</el-button>
            </div>
          </div>
        </div>
      </el-col>
    </el-row>
    <div>
      <el-row>
        <el-col :span="24">
          <el-form ref="form" :model="data" :inline="true" :rules="formRules">
            <el-row :gutter="10">
              <el-col :xl="4" :lg="4" :md="4" :sm="5">
                <el-form-item prop="name">
                  <div>名称</div>
                  <el-input v-model="data.name" size="mini" />
                </el-form-item>
              </el-col>
              <el-col :xl="4" :lg="4" :md="4" :sm="5">
                <el-form-item prop="status">
                  <div>关联类型</div>
                  <el-select v-model="data.status" size="mini">
                    <el-option v-for="(item, index) in status" :key="index" :value="index" :label="item" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :xl="4" :lg="4" :md="4" :sm="5">
                <el-form-item prop="store_id">
                  <div>关联位置</div>
                  <v-select v-model="data.position" action="storeList" />
                </el-form-item>
              </el-col>
              <el-col :xl="4" :lg="4" :md="4" :sm="4">
                <el-form-item prop="sort">
                  <div>排序</div>
                  <el-input v-model="data.sort" size="mini" />
                </el-form-item>
              </el-col>
              <el-col :xl="2" :lg="2" :md="2" :sm="2">
                <el-form-item>
                  <div>操 作</div>
                  <el-button type="primary" icon="el-icon-upload2" size="mini">上传</el-button>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
          <el-tabs>
            <el-tab-pane label="描述">
              <el-row :gutter="10">
                <el-col :span="24">
                  <wangeditor id="content" v-model="data.content" />
                </el-col>
              </el-row>
            </el-tab-pane>
          </el-tabs>
        </el-col>
      </el-row>
    </div>
  </div>
</template>
<script>
import API from '@/api/system/location'
import { theStatus } from '@/utils/options'
import Wangeditor from '@/components/editor/wangeditor'
import VSelect from '@/components/select'
export default {
  inject: ['addOne'],
  components: {
    Wangeditor,
    VSelect
  },
  data() {
    return {
      data: {
        coding: '',
        name: '',
        sort: 100
      },
      theStatus,
      formRules: {
        name: [
          {
            required: true,
            message: '请输入文档名称',
            trigger: 'blur'
          }
        ],
        status: [
          {
            required: true,
            message: '请选择关联类型',
            trigger: 'change'
          }
        ],
        position: [
          {
            required: true,
            message: '请选择关联位置',
            trigger: 'change'
          }
        ],
        sort: [
          {
            required: true,
            message: '请输入排序',
            trigger: 'blur'
          }
        ]
      }
    }
  },
  watch: {},
  created() {},
  methods: {
    save() {
      const thisData = this.data
      const thisForm = this.$refs.form
      this.addOne(API, thisData, thisForm)
    }
  }
}
</script>
